home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: howland.reston.ans.net!torn!news!apollo!saed
- From: saed@engn.uwindsor.ca (Saed Aryan,13325,1100,g)
- Subject: error: undef. but decl. template as member
- X-Nntp-Posting-Host: apollo.engn.uwindsor.ca
- Message-ID: <Do6owF.LKo@news.uwindsor.ca>
- Keywords: template
- Sender: news@news.uwindsor.ca (Usenet)
- Reply-To: saed@engn.uwindsor.ca
- Organization: VLSI Research Group - University of Windsor
- Date: Wed, 13 Mar 1996 02:14:38 GMT
-
- Hi all,
-
- I am curious to know:
-
- --- Why is it not sufficient to declare a template in order to be able to
- use it as a member of a class, and then to define the template class later.
-
- I would like to know whether this is compiler specific or whether it's a C++
- template flaw, since the error does not make logical sense to me.
- The code snippet below shows the problem. If you succeed in compiling this code
- errorless, or if you have an explanataion, I'd be glad to know!
-
- Thanks a lot,
- Aryan.
-
- //----cut here
- template <class T> class A1{}; // A1 declared and defined
- template <class T> class A2; // A2 just declared
-
- class B1 {private: A1<int> a1;};// okay, A1 with template is defined
- class B2 {private: A2<int> a2;};// error: field `a2' has incomplete type
-
- template <class T> class A2{}; //A1 now also defined
-
- main(){};
- //----end code
-
-
-
-
-
-